package com.smt.take.jpush

import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.os.Bundle
import android.text.TextUtils
import android.util.Log
import cn.jpush.android.api.JPushInterface
import com.smt.take.utils.OrderObservable

/**
 *描述: 极光推送广播接收器
 */
class MyJPushReceiver : BroadcastReceiver() {

    override fun onReceive(context: Context, intent: Intent) {
        Log.e("order", "收到推送消息")
        val bundle: Bundle? = intent.extras
        if (bundle != null) {
            val message = bundle.getString(JPushInterface.EXTRA_TITLE)
            Log.e("order", message.toString())
            val extras = bundle.getString(JPushInterface.EXTRA_EXTRA)
            Log.e("order", extras.toString())
            if (!TextUtils.isEmpty(extras)) {
                // 使用观察者模式（orderRvAdapter是观察者，MyJPushReceiver是被观察者）
                OrderObservable.instance.newMsgComing(extras!!)
            }
        }
    }


}